package ee.helmesWorkTest.frontend.controller.formconverters;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

import ee.helmesWorkTest.backend.model.data.Sector;

public class PersonSectorFormRequestProcessor 
{
	private final String EMPTY_STRING = "";
	private final int ID_PARSE_EXCEPTION_INDICATOR = -1;
	
	public PersonSectorFormConverter fillPersonSectorFormConverterWithRequestData(
			HttpServletRequest request)
	{
		PersonSectorFormConverter personSectorFormConverter = 
				new PersonSectorFormConverter();
		String personID = request.getParameter("personID");
		String name = request.getParameter("name");
		String[] arrayOfSelectedSectorIDs = request.getParameterValues("sectorSelection[]");
		String agreesToTerms = request.getParameter("agreeToTermsCheckbox");
		
		HttpSession session = request.getSession();
		List<Sector> listOfAllSectors = (List<Sector>) session.getAttribute("listOfAllSectors");
		
		personSectorFormConverter.setPersonID(personID);
		personSectorFormConverter.setName(name);
		personSectorFormConverter.setArrayOfSelectedSectorIDs(arrayOfSelectedSectorIDs);
		personSectorFormConverter.setAgreesToTerms(agreesToTerms);
		personSectorFormConverter.setListOfAllSectors(listOfAllSectors);
		
		return personSectorFormConverter;
	}
}
